﻿using System.Collections.Generic;
using Phoenix.Xna.Framework.Graphics;

namespace Phoenix.Xna.Framework.Components.Terrain
{
    public class TerrainVertex
    {
        public int BufferIndex { get; set; }
        public int LastIteration { get; set; }
        public bool Enabled { get { return this.References.Count > 0; } }
        public VertexPositionNormal Value { get; set; }
        public List<TerrainNode> References { get; private set; }

        public TerrainVertex(VertexPositionNormal value)
        {
            BufferIndex = 0;
            LastIteration = -1;
            References = new List<TerrainNode>();
            Value = value;
        }

        public void AddReferenceTo(TerrainNode node)
        {
            if (References.IndexOf(node) >= 0)
            {
                return;
            }

            References.Add(node);
        }

        public void RemoveReferenceFrom(TerrainNode node)
        {
            References.Remove(node);
        }
    }
}
